package algorithm.sort.review3;

import java.util.Arrays;

public class Insert {
    public static void main(String[] args) {
        int[] arr = {3, 3, 4, 1, 3, 56, 242, 1};
        insert(arr);
    }
    public static void insert(int[] arr){
        if (arr == null || arr.length == 0 || arr.length == 1) return;
        int index;
        int temp;
        for (int i = 1; i <arr.length; i++) {
            temp = arr[i];
            index = i;
            while(index > 0 && arr[index - 1] > temp){
                arr[index] = arr[index - 1];
                index--;
            }
            arr[index] = temp;
        }
        System.out.println(Arrays.toString(arr));
    }
}
